﻿using ComClassLibrary;
using KeyboardArg;
using System;
using System.Windows;

namespace CountrySelectionKeyBoard
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            string jsonString = "";
            if (e.Args.Length <= 0)
            {
                jsonString = "{\"Content\":\"中国\",\"DictionaryFileName\":\"Citys\",\"Key\":\"GJ\",\"Lang\":\"cn\",\"MaxLength\":5,\"Title\":\"\",\"Value\":null,\"VoiceFileName\":null,\"Wnd\":{\"value\":5835392}}";
            }
            else
            {
                jsonString = e.Args[0].Replace('@', '"');
            }
            KeyBoardArgs args = null;
            try
            {
                args = JsonHandler.ConvertToJsonObject<KeyBoardArgs>(jsonString);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                MessageBox.Show(e.ToString(), "参数错误");
            }
            if (null == args)
            {
                MessageBox.Show(jsonString, "参数错误"); //20170412 取消提示
                return;
            }
            else
            {
                MainWindow mainWindow = new MainWindow(args);
                mainWindow.Show();
            }
        }
    }
}
